<template>
  <div class="app-container">
    <el-table  :data="figureList">
<!--      <el-table-column label="就餐部门" align="center" prop="deptName" />-->
      <el-table-column label="早餐次数" align="center" prop="breakfastTimes" />
      <el-table-column label="早餐免费次数" align="center" prop="breakfastFreeTimes" />
      <el-table-column label="早餐金额" align="center" prop="breakfastAmount" />
      <el-table-column label="午餐次数" align="center" prop="lunchTimes" />
      <el-table-column label="午餐免费次数" align="center" prop="lunchFreeTimes" />
      <el-table-column label="午餐金额" align="center" prop="lunchAmount" />

      <el-table-column label="晚餐次数" align="center" prop="dinnerTimes" />


    </el-table>

    <el-table  :data="figureList">
      <el-table-column label="晚餐免费次数" align="center" prop="dinnerFreeTimes" />
      <el-table-column label="晚餐金额" align="center" prop="dinnerAmount" />
      <el-table-column label="接待餐次数" align="center" prop="receptionMealTimes" />
      <el-table-column label="接待餐免费次数" align="center" prop="receptionMealFreeTimes" />

      <el-table-column label="接待餐金额" align="center" prop="receptionMealAmount" />
      <el-table-column label="就餐总次数" align="center" prop="num" />

<!--      <el-table-column label="其他次数" align="center" prop="otherTimes" />-->
<!--      <el-table-column label="其他金额" align="center" prop="otherAmount" />-->
      <el-table-column label="消费累计金额" align="center" prop="allBigDecimal" />

    </el-table>
  </div>
</template>

<script>
import { statisticsList } from '@/api/ordermanager/order';

export default {
  name: "Figure",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      fileListqiye: [],
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      figureList: [],

      icon: '',
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      MixinUploadAllApi: process.env.VUE_APP_BASE_API + "/file/upload/single",
      // 表单参数
      form: {},
       // 公司信息
      companys: [],
      // 表单校验
      rules: {
         icon: [
          { required: true, message: "轮播图不能为空", trigger: "blur" }
        ],
        companyId: [
            { required: true, message: '请选择所属公司', trigger: 'change' }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      statisticsList(this.queryParams).then(response => {
        this.figureList = response.data;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        name: undefined,
        url: undefined,
        icon: undefined,
        type: undefined,
        param: undefined,
        status: "0",
        priority: undefined,
        description: undefined
      };
      this.resetForm("form");
    },
         // 主体
    uploadSuccess(res) {
      console.log(res)
      this.icon = res.data
      this.form.icon = res.data;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加轮播图片";
      this.fileListqiye = [];
      this.form.icon = '';
    },
        /** 图片上传之前的校验  */
    beforeImgUpload(file) {
      const isLt1M = file.size / 5120 / 5120 < 1;
      if (!isLt1M) {
        this.msgWarning("上传图片大小不能超过 5MB!");
      }
      var FileExt = file.name.replace(/.+\./, "");
      if (["jpg", "jpeg", "png"].indexOf(FileExt.toLowerCase()) === -1) {
        this.msgWarning("请上传后缀名为jpg/jpeg/png的图片附件！");
        return false;
      }
      return isLt1M;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getFigure(id).then(response => {
        this.form = response.data;
        this.icon = response.data.icon
        this.open = true;
        this.title = "修改轮播图片";
        this.form.icon = response.data.icon;
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      // this.form.icon = this.icon;
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateFigure(this.form).then(response => {
              if (response.code == 0) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addFigure(this.form).then(response => {
              if (response.code == 0) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delFigure(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有【请填写功能名称】数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportFigure(queryParams);
        }).then(response => {
          this.download(response.data);
        }).catch(function() {});
    },
    /** 获取公司信息 */
    getCompanyList() {
      getCompanys().then(response => {
        this.companys = response.data;
      });
    },
  }
};
</script>
<style>
 .news-image {
    width: 50px;
    height: 50px;
  }
  .updateimg {
  width: 20%;
  max-width: 500px;
  min-width: 200px;
  float: left;
}
 .iconImg{
   max-width: 500px;
 }
</style>
